import { useState, useCallback, useEffect } from 'react';
//自定义hooks 获取当前宽度
function useWidth() {
  const [width, setWidth] = useState(document.body.clientWidth);
  const change = () => {
    setWidth(document.body.clientWidth);
  };
  useEffect(() => {
    window.addEventListener('resize', change, false);
  }, []);
  return width;
}

export default useWidth;
